-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[No QA] Remove default values for IDs to comply with eslint rules #54306
base: main
Are you sure you want to change the base?
[No QA] Remove default values for IDs to comply with eslint rules #54306
Conversation
@paultsimura Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
cc @VickyStash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some comments, will take more thorough look tomorrow! 👀
src/libs/actions/Report.ts
Outdated
// API expects a string, that's why policyID must default to a string | ||
// eslint-disable-next-line rulesdir/no-default-id-values | ||
parentReportID: currentTask.parentReportID ?? '', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
API expects a string
Are you sure? How was it before TS migration? Is it be possible to call this API call without parentReportID
or with invalid parentReportID
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@VickyStash I'm not sure what the API expects or how to test it, but currently we send '-1' in case currentTask.parentReportID
is undefined
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Answered here: #54306 (comment)
src/libs/actions/Report.ts
Outdated
// API expects a string, that's why policyID must default to a string | ||
// eslint-disable-next-line rulesdir/no-default-id-values | ||
const searchForRoomToMentionParams: SearchForRoomsToMentionParams = {query: searchInput, policyID: policyID ?? ''}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same question here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Should it be possible to call this request without a valid
policyID
? - If yes - can we pass undefined instead of '' string?
- If no - add a condition to prevent it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@VickyStash I'm not sure what the API expects or how to test it, but currently we send '-1' in case policyID
is undefined
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Answered here: #54306 (comment)
src/ROUTES.ts
Outdated
getRoute: (policyID: string, backTo?: string) => `${getUrlWithBackToParam(`settings/workspaces/${policyID}`, backTo)}` as const, | ||
getRoute: (policyID = '', backTo?: string) => `${getUrlWithBackToParam(`settings/workspaces/${policyID}`, backTo)}` as const, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the initial idea of this ESlint change was to make sure the real values are passed where needed. And the missing data to be correctly handled where the function is being called.
For instance, we shouldn't change these getRoute
functions, but throw something when we don't have the policyID
when calling WORKSPACE_INITIAL.getRoute()
.
@iwiznia please correct me if I'm wrong. And what should we do when we don't have a policy ID but need to navigate to this page?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think any of these routes should be used by passing an empty policyID
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think it makes more sense to add the condition on level above to make sure WORKSPACE_INITIAL.getRoute(...)
not called without policy id. Same for other cases here.
@pac-guerreiro let's try to do it so
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@iwiznia @paultsimura @VickyStash
getRoute(...)
is mostly used in Navigation.navigate(...)
and I'm worried that if we prevent it from running we'll disrupt normal app flow
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we just do it like this ROUTES.REPORT_WITH_ID.getRoute(
`${report.preexistingReportID}
`)
?
This way we still navigate the user to the new page but we pass undefined as string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you tried to navigate to the page with invalid id? What results do you get
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@VickyStash if the id is invalid, the page will show a Not found
page but it seems that all reports in Onyx are deleted
src/libs/actions/Report.ts
Outdated
if (shouldDismissModal) { | ||
Navigation.dismissModalWithReport(report); | ||
} else { | ||
Navigation.navigateWithSwitchPolicyID({route: ROUTES.HOME}); | ||
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(report?.reportID ?? '-1'), actionType); | ||
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(report?.reportID), actionType); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sure it's not called if there is no report?.reportID
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But if I prevent navigation from happening it will disrupt normal user flow 🤔 Shouldn't we warn the user that there was some problem, or something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's try to test it as I mentioned here. What happens if you navigate user to the screen with -1
id
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@VickyStash if the id is invalid, the page will show a Not found page but it seems that all reports in Onyx are deleted
src/libs/actions/Report.ts
Outdated
// API expects a string, that's why parentReportID must default to a string | ||
// eslint-disable-next-line rulesdir/no-default-id-values | ||
parentReportID: currentTask.parentReportID ?? '', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Should it be possible to call this request without a valid
parentReportID
? - If yes - can we pass undefined instead of '' string?
- If no - add a condition to prevent it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know that information, where can I get it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideas:
- try to call the API call with
''
,-1
and withundefined
asparentReportID
- check if it makes any difference - check if the defaulting value always was there
src/libs/actions/Report.ts
Outdated
// API expects a string, that's why policyID must default to a string | ||
// eslint-disable-next-line rulesdir/no-default-id-values | ||
const searchForRoomToMentionParams: SearchForRoomsToMentionParams = {query: searchInput, policyID: policyID ?? ''}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Should it be possible to call this request without a valid
policyID
? - If yes - can we pass undefined instead of '' string?
- If no - add a condition to prevent it
…on-report-actions # Conflicts: # src/libs/actions/Report.ts
…on-report-actions
I applied most of the suggestions but left some questions 😄 |
@pac-guerreiro left suggestions to some of your questions! |
Today I resolved the remaining eslint issues 😄 @VickyStash I left some replies but I wasn't able to confirm what the API expects in some situations. I guess it should be face to pass undefined for those ids. I'll be away until January 2nd but someone should take care of my work 😄 Happy holidays! 🎉 |
Explanation of Change
Fixed Issues
$#50360
PROPOSAL:
?? '-1'
and?? '0'
defaults for IDs insrc/libs/actions/Report.ts
Tests
N/A
Offline tests
N/A
QA Steps
N/A
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)src/languages/*
files and using the translation methodSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label and/or tagged@Expensify/design
so the design team can review the changes.ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Android: Native
N/A
Android: mWeb Chrome
N/A
iOS: Native
N/A
iOS: mWeb Safari
N/A
MacOS: Chrome / Safari
N/A
MacOS: Desktop
N/A